﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using rock.DAL;
using rock.common;
using rock.UI.fee;

namespace rock.UI.message
{
    public partial class UserControlMessageShaoZhujing : UserControl
    {
        DalFEE_ROOM aDalFEE_ROOM = new DalFEE_ROOM();
        int CURRENT_NOTIFY_DAY = 0;
        public UserControlMessageShaoZhujing()
        {
            InitializeComponent();
            this.Dock = System.Windows.Forms.DockStyle.Fill;
            ViewUtils.setDataGridViewStlye(this.dataGridView1);
        }

        private void UserControlMessageContract_Load(object sender, EventArgs e)
        {
            CURRENT_NOTIFY_DAY = 0;
            refreshData(0);
        }

        private void radioButton0_CheckedChanged(object sender, EventArgs e)
        {
            if (!radioButton0.Checked)
            {
                return;
            }
            CURRENT_NOTIFY_DAY = 0;
            refreshData(0);
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            if (!radioButton3.Checked)
            {
                return;
            }
            CURRENT_NOTIFY_DAY = 3;
            refreshData(3);
        }

        private void radioButton7_CheckedChanged(object sender, EventArgs e)
        {
            if (!radioButton7.Checked)
            {
                return;
            }
            CURRENT_NOTIFY_DAY = 7;
            refreshData(7);

        }

        private void radioButton15_CheckedChanged(object sender, EventArgs e)
        {
            if (!radioButton15.Checked)
            {
                return;
            }
            CURRENT_NOTIFY_DAY = 15;
            refreshData(15);
        }

        private void radioButton30_CheckedChanged(object sender, EventArgs e)
        {
            if (!radioButton30.Checked)
            {
                return;
            }
            CURRENT_NOTIFY_DAY = 30;
            refreshData(30);
        }


        private void refreshData(int notifyDate) {
            DataSet ds = aDalFEE_ROOM.GetShaoZhujingNotifyMessage(CURRENT_NOTIFY_DAY);
            this.dataGridView1.DataSource = ds.Tables[0]; 
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                String CUSTOM_SEQID = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["CUSTOM_SEQID"].Value.ToString();
                String CONTRACT_SEQID = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["CONTRACT_SEQID"].Value.ToString();
                // this.textBox1.Text = value;
                FormFeeShaoRoomZhujing ffsz = new FormFeeShaoRoomZhujing();

                ffsz._ModelFEE_ROOM.CUSTOM_SEQID = Convert.ToInt32(CUSTOM_SEQID);
                ffsz._ModelFEE_ROOM.CONTRACT_SEQID = Convert.ToInt32(CONTRACT_SEQID);

                ffsz.oneRefreshParentData = this.refreshData;
                ffsz.ShowDialog(this);

               
                //注册代理
               
            }
            else
            {
                MessageBox.Show("请选择要查看的记录.", "提示");
            }
           
        }

        private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                row.Cells[0].Value = row.Index + 1;
            }
        }
         
    }
}
